# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_docker//container:container.bzl", "container_push")
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
    name = "certmgr_lib",
    srcs = ["certmgr_server.go"],
    importpath = "px.dev/pixie/src/vizier/services/certmgr",
    visibility = ["//visibility:private"],
    deps = [
        "//src/shared/services",
        "//src/shared/services/healthz",
        "//src/shared/services/server",
        "//src/vizier/services/certmgr/certmgrenv",
        "//src/vizier/services/certmgr/certmgrpb:service_pl_go_proto",
        "//src/vizier/services/certmgr/controllers",
        "@com_github_gofrs_uuid//:uuid",
        "@com_github_nats_io_nats_go//:nats_go",
        "@com_github_sirupsen_logrus//:logrus",
        "@com_github_spf13_pflag//:pflag",
        "@com_github_spf13_viper//:viper",
    ],
)

go_binary(
    name = "certmgr",
    embed = [":certmgr_lib"],
    visibility = ["//visibility:public"],
)

go_image(
    name = "certmgr_server_image",
    binary = ":certmgr",
    visibility = [
        "//k8s:__subpackages__",
        "//src/vizier:__subpackages__",
    ],
)

container_push(
    name = "push_certmgr_server_image",
    format = "Docker",
    image = ":certmgr_server_image",
    registry = "gcr.io",
    repository = "pixie-oss/pixie-dev/vizier/certmgr_server_image",
    tag = "{STABLE_BUILD_TAG}",
)
